libxenstore: filter watch events in libxenstore when we unwatch
authorJulien Grall <julien.grall@citrix.com>
Mon, 17 Dec 2012 18:04:54 +0000 (18:04 +0000)
committerJulien Grall <julien.grall@citrix.com>
Mon, 17 Dec 2012 18:04:54 +0000 (18:04 +0000)
commitb6372f16d3f1cf48cd2ff21ab4bdc25cc05d69fd
treefdae973b00e47cc10a1bbf6ad239e30017f34731
parent77ad1faa6b6147770feece6a59e21b28c0e0788f
libxenstore: filter watch events in libxenstore when we unwatch

XenStore puts in queued watch events via a thread and notifies the user.
Sometimes xs_unwatch is called before all related message is read. The use
case is non-threaded libevent, we have two event A and B:
    - Event A will destroy something and call xs_unwatch;
    - Event B is used to notify that a node has changed in XenStore.
As the event is called one by one, event A can be handled before event B.
So on next xs_watch_read the user could retrieve an unwatch token and
a segfault occured if the token store the pointer of the structure
(ie: "backend:0xcafe").

To avoid problem with previous application using libXenStore, this behaviour
will only be enabled if XS_UNWATCH_FILTER is given to xs_open.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xenstore/xenstore.h
tools/xenstore/xs.c